import { ApiProperty } from '@nestjs/swagger';
import { Exclude } from 'class-transformer';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('smtp')
export class Smtp {
  @ApiProperty({ description: 'id' })
  @PrimaryGeneratedColumn()
  id: number; // 标记为主列，值自动生成

  @Column({ comment: '发送邮件账号' })
  fromEmail: string;

  @Column({ comment: '接收邮件账号' })
  toEmail: string;

  @Column({ type: 'text', comment: '邮件主体', default: null })
  subject: string;

  @Exclude()
  @Column({ type: 'text', comment: '邮件内容', default: null })
  text: string;

  @Column({
    comment: '是否发送成功 true 成功  | false 失败',
  })
  isSuccess: boolean; // 是否发送成功

  @ApiProperty({ description: '创建时间' })
  @Column({
    type: 'timestamp',
    comment: '创建时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createTime: Date;

  @ApiProperty({ description: '修改时间' })
  @Column({
    type: 'timestamp',
    comment: '修改时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  updateTime: Date;
}
